package Thread;

import java.util.Scanner;

public class Demo6 {
    private static boolean run = true;
    public static void main(String[] args) {

        Thread t= new Thread(() -> {
           while(run){
               System.out.println("hello");
               try {
                   Thread.sleep(1_000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        });
        t.start();
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入：");
        int n = scanner.nextInt();
        if(n == 0){
            run = false;
        }
    }
}
